<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>我是一个div</div>
    <script>
        let div = document.querySelector('div');
        // let s = new Set();
        let s = new WeakSet();//弱引用,无需删除,内存自会回收
        s.add(div);
        document.body.removeChild(div);
        // dom对象依然在内存中，因为Set中依然引用此对象
        div = null;
    </script>
</body>
</html>